#include <iostream>
#include <vector>
#include <unordered_set>

using namespace std;

// 1695. 删除子数组的最大得分
// https://leetcode.cn/problems/maximum-erasure-value/

class Solution {
public:
    int maximumUniqueSubarray(vector<int>& nums) {
        int sum = 0;
        int ans = 0;
        int left = 0;
        int n = nums.size();
        unordered_set<int> recordNum;
        for (int i = 0; i < n; i++)
        {
            int curNum = nums[i];
            while(recordNum.find(curNum) != recordNum.end()){
                int delNum = nums[left++];
                recordNum.erase(delNum);
                sum -= delNum;
            }
            recordNum.insert(curNum);
            sum += curNum;
            ans = max(ans, sum);
        }
        return ans;
    }
};

int main()
{
    return 0;
}